/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 * @author : asus
 */
var delay = 2000;
var intervalUserChat;
var active_chat_id;


function ajax(file,fungsi){
    if (window.XMLHttpRequest){
        xmlhttp=new XMLHttpRequest();
    }
    else{
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlhttp.onreadystatechange=fungsi;
    xmlhttp.open("GET",file,true);
    xmlhttp.send();
}

function initUserPage() {
    updateUserPage();
    intervalUserChat = setInterval(updateUserPage, delay);
}

function updateUserPage() {
    //update all
}

function updateFriendList() {
    //update friendlist
}

function updateRoomList() {
    
}

function updateUserRoom() {
    // only in active chat id (viewed chat id)
    ajax("../controller/showChat.jsp?",function(){
        if (xmlhttp.readyState==4 && xmlhttp.status==200){
            document.getElementById("chatArea").innerHTML=xmlhttp.responseText;
        }
    });
}

/*
 * init chat user
 **/
function addActiveChatUser(uid) {
    
}

function getChatUser(id) {
    
}

/*
 * init chat rooms
 **/
function addActiveChatRoom(rid) {

}

/*
 * CHAT CONTENT
 **/
function closeAnActiveChat(chat_id) {
    
}

function sendMsgToRoom(chat_id, content) {

}

function sendMsgToUser(chat_id, content) {

}

//if user press 'enter'
function chat_on_input_keypress (e, chat_id) {
    
}